﻿using AgileLogistics.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AgileLogistics.View.Meishi.CURD
{
    /// <summary>
    /// ListPage.xaml 的交互逻辑
    /// </summary>
    public partial class ListPage : Page
    {
        public ListPage()
        {
            InitializeComponent();
            vm = DataContext as ViewModel.MenuViewModel;
        }


        ViewModel.MenuViewModel vm;
        private void btn_DeleteClick(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;
           var menu = btn.Tag as Model.Menus;

            if(HandyControl.Controls. MessageBox.Show("确定要删除该菜品吗？" ,"提示",MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes)
            {

            }
            DBContext context = new  DBContext();
            context.DB.Deleteable<Menus>(menu).ExecuteCommand();

            vm.MenusList = new System.Collections.ObjectModel.ObservableCollection<Menus>( context.DB.Queryable<Menus>().ToList());

        }
    }
}
